import { userLoginAPI } from '@/api/userApi'
import { setToken } from '@/utils/auth'

const actions = {
  async userLoginAction(context, user) {
    const { data } = await userLoginAPI(user)
    context.commit('setToken', data)
    return data
  }
}

const mutations = {
  setToken(state, token) {
    state.token = token
    setToken(token)
  }
}
const state = {
  token: ''
}

export default {
  namespaced: true, state, mutations, actions
}
